<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			var random = parseInt(Math.random()*100+1);
				console.log(random);
			function cai(){
				var input1 = parseInt(document.getElementById("inputId").value); 
					var input2 = document.getElementById("spanId");
					if (isNaN(input1)) {
					input2.innerHTML = "输入不合法";
				}
				if (random==input1) {
					input2.innerHTML = "猜对了";
				}
				if (random>input1) {
					input2.innerHTML = "小了";
				}
				if (random<input1) {
					input2.innerHTML = "大了";
				}
			}

			
		</script>
	</head>
	<body>
		<p>猜数字游戏</p>
		<input type="text" id="inputId" />
		<button onclick="cai()">猜</button>
		<span id="spanId"></span>
	</body>
</html>
